package gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

public class TelaPrincipal extends JFrame {

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JPanel processoPanel = null;
    private JLabel processoLabel = null;
    private JTextField processoField = null;
    private JLabel pageNumberLabel = null;
    private JComboBox pagesNumberComboBox = null;
    private JLabel framesNumberLabel = null;
    private JComboBox framesNumberComboBox = null;
    private JLabel tamanhoLabel = null;
    private JComboBox tamanhoComboBox = null;
    private JButton startButton = null;
    private JButton cancelButton = null;
    private JPanel memoriaVirtualPanel = null;
    private JPanel memoriaRamPanel = null;
    private JLabel tamProcesso = null;
    private JComboBox tamProcessoComboBox = null;
    private JPanel painelControlePanel = null;

    /**
     * This is the default constructor
     */
    public TelaPrincipal() {
        super();
        initialize();
    }

    /**
     * This method initializes this
     *
     * @return void
     */
    private void initialize() {
        this.setSize(324, 314);
        this.setContentPane(getJContentPane());
        this.setTitle("Simulador - Gerenciamento de Memória do S.O.");
        this.setResizable(false);
        this.setVisible(true);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    /**
     * This method initializes jContentPane
     *
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(null);
            jContentPane.add(getProcessoPanel(), null);
            jContentPane.add(getMemoriaVirtualPanel(), null);
            jContentPane.add(getMemoriaRamPanel(), null);
            jContentPane.add(getPainelControlePanel(), null);
            jContentPane.add(getStartButton(), null);
            jContentPane.add(getCancelButton(), null);
        }
        return jContentPane;
    }

    /**
     * This method initializes processoPanel
     *
     * @return javax.swing.JPanel
     */
    private JPanel getProcessoPanel() {
        if (processoPanel == null) {
            tamProcesso = new JLabel();
            tamProcesso.setBounds(new Rectangle(15, 47, 186, 16));
            tamProcesso.setText("Tamanho Processo em Pagina:");
            tamanhoLabel = new JLabel();
            tamanhoLabel.setText("Tamanho da Pagina/Frames:");
            tamanhoLabel.setBounds(new Rectangle(6, 24, 167, 16));
            framesNumberLabel = new JLabel();
            framesNumberLabel.setText("Numero de Frames: ");
            framesNumberLabel.setBounds(new Rectangle(7, 24, 123, 16));
            pageNumberLabel = new JLabel();
            pageNumberLabel.setText("Numero de Páginas:");
            pageNumberLabel.setBounds(new Rectangle(8, 19, 126, 16));
            processoLabel = new JLabel();
            processoLabel.setBounds(new Rectangle(15, 21, 125, 16));
            processoLabel.setText("Nome do Processo:");
            processoPanel = new JPanel();
            processoPanel.setLayout(null);
            processoPanel.setBounds(new Rectangle(4, 4, 308, 76));
            processoPanel.setBorder(BorderFactory.createTitledBorder(
                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    "Processo", TitledBorder.CENTER,
                    TitledBorder.DEFAULT_POSITION, new Font("Dialog",
                    Font.BOLD, 12), new Color(51, 51, 51)));
            processoPanel.add(processoLabel, null);
            processoPanel.add(getProcessoField(), null);
            processoPanel.add(tamProcesso, null);
            processoPanel.add(getTamProcessoComboBox(), null);
        }
        return processoPanel;
    }

    /**
     * This method initializes processoField
     *
     * @return javax.swing.JTextField
     */
    private JTextField getProcessoField() {
        if (processoField == null) {
            processoField = new JTextField();
            processoField.setBounds(new Rectangle(148, 21, 134, 20));
            processoField.setText("Processo1");
        }
        return processoField;
    }

    /**
     * This method initializes pagesNumberComboBox
     *
     * @return javax.swing.JComboBox
     */
    private JComboBox getPagesNumberComboBox() {
        if (pagesNumberComboBox == null) {
            pagesNumberComboBox = new JComboBox(new Integer[]{16});
            pagesNumberComboBox.setBounds(new Rectangle(143, 19, 67, 21));
            pagesNumberComboBox.setSelectedItem(new Integer(16));
        }
        return pagesNumberComboBox;
    }

    /**
     * This method initializes framesNumberComboBox
     *
     * @return javax.swing.JComboBox
     */
    private JComboBox getFramesNumberComboBox() {
        if (framesNumberComboBox == null) {
            framesNumberComboBox = new JComboBox(new Integer[]{4});
            framesNumberComboBox.setBounds(new Rectangle(144, 20, 67, 21));
            framesNumberComboBox.setSelectedItem(new Integer(4));
        }
        return framesNumberComboBox;
    }

    /**
     * This method initializes tamanhoComboBox
     *
     * @return javax.swing.JComboBox
     */
    private JComboBox getTamanhoComboBox() {
        if (tamanhoComboBox == null) {
            tamanhoComboBox = new JComboBox(new String[]{"4k"});
            tamanhoComboBox.setBounds(new Rectangle(178, 21, 56, 21));
            tamanhoComboBox.setSelectedItem("4k");
        }
        return tamanhoComboBox;
    }

    /**
     * This method initializes startButton
     *
     * @return javax.swing.JButton
     */
    private JButton getStartButton() {
        if (startButton == null) {
            startButton = new JButton();
            startButton.setText("Iniciar Gerenciamento");
            startButton.setBounds(new Rectangle(149, 255, 159, 25));
            startButton.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent e) {
                    new TelaGerenciamento(processoField.getText(),
                            (Integer) pagesNumberComboBox.getSelectedItem(),
                            (Integer) framesNumberComboBox.getSelectedItem(),
                            (Integer) tamProcessoComboBox.getSelectedItem(),
                            (String) tamanhoComboBox.getSelectedItem());
                    TelaPrincipal.this.dispose();
                }
            });
        }
        return startButton;
    }

    /**
     * This method initializes cancelButton
     *
     * @return javax.swing.JButton
     */
    private JButton getCancelButton() {
        if (cancelButton == null) {
            cancelButton = new JButton();
            cancelButton.setText("Cancel");
            cancelButton.setBounds(new Rectangle(57, 254, 80, 25));
            cancelButton.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent e) {
                    System.exit(0);
                }
            });
        }
        return cancelButton;
    }

    /**
     * This method initializes memoriaVirtualPanel
     *
     * @return javax.swing.JPanel
     */
    private JPanel getMemoriaVirtualPanel() {
        if (memoriaVirtualPanel == null) {
            memoriaVirtualPanel = new JPanel();
            memoriaVirtualPanel.setLayout(null);
            memoriaVirtualPanel.setBounds(new Rectangle(5, 83, 307, 50));
            memoriaVirtualPanel.setBorder(BorderFactory.createTitledBorder(
                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    "Memória Virtual", TitledBorder.CENTER,
                    TitledBorder.DEFAULT_POSITION, new Font("Dialog",
                    Font.BOLD, 12), new Color(51, 51, 51)));
            memoriaVirtualPanel.add(pageNumberLabel, null);
            memoriaVirtualPanel.add(getPagesNumberComboBox(), null);
        }
        return memoriaVirtualPanel;
    }

    /**
     * This method initializes memoriaRamPanel
     *
     * @return javax.swing.JPanel
     */
    private JPanel getMemoriaRamPanel() {
        if (memoriaRamPanel == null) {
            memoriaRamPanel = new JPanel();
            memoriaRamPanel.setLayout(null);
            memoriaRamPanel.setBounds(new Rectangle(6, 138, 306, 55));
            memoriaRamPanel.setBorder(BorderFactory.createTitledBorder(
                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    "Memória RAM", TitledBorder.CENTER,
                    TitledBorder.DEFAULT_POSITION, new Font("Dialog",
                    Font.BOLD, 12), new Color(51, 51, 51)));
            memoriaRamPanel.add(framesNumberLabel, null);
            memoriaRamPanel.add(getFramesNumberComboBox(), null);
        }
        return memoriaRamPanel;
    }

    /**
     * This method initializes tamProcessoComboBox
     *
     * @return javax.swing.JComboBox
     */
    private JComboBox getTamProcessoComboBox() {
        if (tamProcessoComboBox == null) {
            tamProcessoComboBox = new JComboBox(new Integer[]{4,5,6,7,8,9,10});
            tamProcessoComboBox.setBounds(new Rectangle(212, 45, 70, 21));
            tamProcessoComboBox.setSelectedItem(new Integer(10));
        }
        return tamProcessoComboBox;
    }

    /**
     * This method initializes painelControlePanel
     *
     * @return javax.swing.JPanel
     */
    private JPanel getPainelControlePanel() {
        if (painelControlePanel == null) {
            painelControlePanel = new JPanel();
            painelControlePanel.setLayout(null);
            painelControlePanel.setBounds(new Rectangle(7, 197, 304, 52));
            painelControlePanel.setBorder(BorderFactory.createTitledBorder(
                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    "Tamanho das Páginas / Frame" + "", TitledBorder.CENTER,
                    TitledBorder.DEFAULT_POSITION, new Font("Dialog",
                    Font.BOLD, 12), new Color(51, 51, 51)));
            painelControlePanel.add(tamanhoLabel, null);
            painelControlePanel.add(getTamanhoComboBox(), null);
        }
        return painelControlePanel;
    }
} // @jve:decl-index=0:visual-constraint="10,10"

